#include <stdio.h>
#include <stdlib.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define MAX_COUNT 100000

int list[MAX_COUNT] = { 0 };

int main(int argc, char const *argv[])
{
    int cbj, maxj, zfj, outn, j, n, il, ir;
    int i, k, step, bt, maxlr, maxlrj, lr;
    scanf("%d", &zfj);
    scanf("%d%d", &j, &n);
    list[j] = n;
    cbj = j;
    maxj = j;
    while (1)
    {
        scanf("%d%d", &j, &n);
        if (j == -1 && n == -1)
        {
            break;
        }
        list[j] = n;
        maxj = max(maxj, j);
    }
    scanf("%d", &outn);
    
    il = cbj;
    ir = cbj + 1;

    while (ir < maxj)
    {
        //找到相邻的一个数
        while (ir <= maxj && list[ir] == 0)
        {
            ir++;
        }

        //找不到，跳出
        if (ir > maxj)
        {
            break;
        }

        step = (list[il] - list[ir]) / (ir - il);
        
        for (i = il + 1; i < ir; i++)
        {
            list[i] = list[i - 1] - step; 
        }

        il = ir;
        ir = ir + 1;
    }
    j = maxj;
    n = list[maxj];
    while (n > 0)
    {
        n -= outn;    
        list[++j] = n;
    }
    maxj = j;

    for (bt = 0; bt < 100000; bt++)
    {
        maxlr = -2147483647;
        maxlrj = 0;
        for (i = cbj; i < maxj; i++)
        {
            lr = (i - cbj + bt) * list[i];
            if (max(maxlr, lr) == lr)
            {
                maxlrj = i;
                maxlr = lr;
            }
        }
        if (maxlrj == zfj)
        {
            printf("%d", bt);
            return 0;
        }
        
        maxlr = -2147483647;
        maxlrj = 0;
        for (i = cbj; i < maxj; i++)
        {
            lr = (i - cbj - bt) * list[i];
            if (max(maxlr, lr) == lr)
            {
                maxlrj = i;
                maxlr = lr;
            }
        }
        if (maxlrj == zfj)
        {
            printf("%d", -bt);
            return 0;
        }
    }
    printf("NO SOLUTION");
    return 0;
}
